﻿using System.Collections.Generic;

namespace SiteApp.BLL.Common
{
    /// <summary>
    /// 去除重复项
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <returns></returns>
    public delegate bool EqualsComparer<T>(T x, T y);
    public class ComparerHelper<T> : IEqualityComparer<T>
    {
        private EqualsComparer<T> _equalsComparer;
        public ComparerHelper(EqualsComparer<T> equalsComparer)
        {
            this._equalsComparer = equalsComparer;
        }
        public bool Equals(T x, T y)
        {
            if (null != this._equalsComparer)
                return this._equalsComparer(x, y);
            else
                return false;
        }
        public int GetHashCode(T obj)
        {
            return obj.ToString().GetHashCode();
        }
    }
}
